package com.day0929.try_catch;

public class Student {
    private String name;
    private int age;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) throws Exception {
        if (age < 0 || age > 130){
            Exception exception = new Exception("年龄不能小于0或大于130");
            throw exception;
        }
        this.age = age;
    }

    public static void main(String[] args) throws Exception {
        Student student = new Student();
        student.setAge(10);
        System.out.println(student.getAge());
    }
}
